#include <buola/gui/x11/auto.h>

#include <buola/gui/x11/ccomposite.h>
#include <buola/gui/x11/cx11display.h>

namespace buola { namespace gui { namespace x11 {

int CComposite::mOp;
int CComposite::mEv;
int CComposite::mErr;
int CComposite::mMajor;
int CComposite::mMinor;

void CComposite::InitExtension()
{
    if(!XQueryExtension(get_default_x11_display()->GetDisplay(),COMPOSITE_NAME,
                                    &mOp,&mEv,&mErr))
    {
        throw XInternal(I18N("No composite extension"));
    }
    
    XCompositeQueryVersion(get_default_x11_display()->GetDisplay(),&mMajor,&mMinor);

    if(mMajor<1&&mMinor<2)
    {
        throw XInternal(I18N("must have composite extension >= 0.2"));
    }
}

Pixmap CComposite::NamePixmap(Drawable pD)
{
    Pixmap lReturn=XCompositeNameWindowPixmap(get_default_x11_display()->GetDisplay(),pD);
    return lReturn;
}

void CComposite::RedirectSubwindows(Window pWindow)
{
    XCompositeRedirectSubwindows(get_default_x11_display()->GetDisplay(),pWindow,
                                    CompositeRedirectManual);
}

/*namespace x11*/ } /*namespace gui*/ } /*namespace buola*/ }
